using System;

namespace Onion.Core
{
   public interface IInversionOfControlContainer
   {
      T Resolve<T>();
   }

   public class IoC
   {
      public static T Resolve<T>()
      {
         return InversionOfControlContainer.Resolve<T>();
      }

      private static IInversionOfControlContainer _inversionOfControlContainer;
      public static IInversionOfControlContainer InversionOfControlContainer
      {
         set { _inversionOfControlContainer = value; }
         get
         {
            if (_inversionOfControlContainer == null)
               throw new ApplicationException("Inversion of control container must be set during application startup.");

            return _inversionOfControlContainer;
         }
      }
   }
}